Per Capita COVID-19 cases worldwide
GIS plot of per capita cases of COVID-19 all over the world
Today we will make the Per Capita covid cases worldwide from the article Coronavirus Map: Tracking the Global Outbreak that looks like the following -

# For downloading the map zipped shapefiles
import zipfile
import requests
from io import BytesIO
# For the usual plotting and reading shapefiles
import altair as alt
import pandas as pd
import geopandas as gpd
We will use the JHU CSSE Dataset for the cases as well as the population. For the map we will use the shapefiles from Natural Earth.
population_uri = 'https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/UID_ISO_FIPS_LookUp_Table.csv'
population_data = pd.read_csv(population_uri)
latest_cases_uri = 'https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_daily_reports/10-29-2020.csv'
latest_cases = pd.read_csv(latest_cases_uri)
world_shapefile_uri = "https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/ne_10m_admin_0_countries.zip"
request = requests.get(world_shapefile_uri)
file_ = zipfile.ZipFile(BytesIO(request.content))
file_.extractall()
world_shapefile = 'ne_10m_admin_0_countries.shp'
world = gpd.read_file(world_shapefile)
We have to make some changes so that we get things right. For example there's quite a few names to change for the countries because the cases dataset doesn't have identifier informations. Then in the map file we have to merge a few countries and segregate a few based on how JHU CSSE reports their cases.
latest_cases.head()
latest_cases[latest_cases['Country_Region'].str.contains('Denmark')]
latest_cases.loc[latest_cases['Province_State']=='Greenland', 'Country_Region'] = "Greenland"
population_data.loc[population_data['Province_State']=='Greenland', 'Country_Region'] = "Greenland"
population_data.loc[population_data['Province_State']=='Greenland', 'Combined_Key'] = "Greenland"
latest_cases = latest_cases.drop(['FIPS', 'Admin2', 'Province_State', 'Last_Update', 'Lat', 'Long_', 'Combined_Key', 'Incidence_Rate', 'Case-Fatality_Ratio'], axis=1)
latest_cases = latest_cases.groupby('Country_Region').aggregate({'Confirmed': 'sum', 'Recovered': 'sum', 'Deaths': 'sum', 'Active': 'sum', })
latest_cases = latest_cases.reset_index()
latest_cases.head()
world = world[~(world['CONTINENT']=='Antarctica')]
world = world[['SOVEREIGNT', 'ADMIN', 'NAME', 'POP_EST', 'POP_YEAR', 'ISO_A3', 'CONTINENT', 'geometry']]
world.head()
alt.Chart(world).mark_geoshape(stroke='white').encode().project('equalEarth')